<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>        
  	
  </head>
  <body>
  	<input type="button" class="btn btn-mini btn-info" 		value="增  加" id="add">
  	<input type="button" class="btn btn-mini btn-success" value="修  改" id="modify">
  	<input type="button" class="btn btn-mini btn-danger" 	value="删  除" id="delete">
    <div class="accordion-group widget-box">
      <div class="accordion-heading">
        <div class="widget-title"> 
        	<a data-parent="#collapse-group" href="#collapseGOne" data-toggle="collapse" class="collapsed">
         	<span class="icon"><i class="icon-search"></i></span>
          	<h5>检索条件</h5>
          	</a> 
        </div>
      </div>
      <div class="accordion-body in collapse" id="collapseGOne" style="height: auto;">
        <div class="form-horizontal">
        	<div class="control-group">
              <label class="control-label">单位名称 :</label>
              <div class="controls">
              		<input type="text" placeholder="Company Name" class="span10" id="companyName" >
              		<div class="button-search-right">
              			<input type="button" class="btn btn-success" value="检  索" id="searchButton" onclick="searchResult();">
              		</div>
              </div>
            </div>
        </div>
      </div>
    </div>
    
    <hr />
    <table id="tabGrid"></table>
    <div id="pager"></div>
  </body>
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery/jqGridUtil-min.js"></script>
    <script type="text/javascript">
	    jQuery(function(){
	    	var configCompany = {
	           	url:'<%=request.getContextPath() %>/xtgl/company/companyList.html?doType=query',
	           	colModel:[
	           		{label:'company_id',name:"company_id",index:'company_id', key:true ,hidden:true},
	           		{label:'单位名称',name:"company_name",index:'company_name', width:"35%"},
	           		{label:'简介说明',name:"comment",index:'comment'},
	           		{label:'counts',name:"counts",index:'counts',hidden:true}
	           	],
	           	table:"#tabGrid",
	           	pager: "#pager",
	           	sortname: 'insert_dt',
	            sortorder: "desc",
	            caption:"单位信息列表"
	      };
	    	jQuery.loadGrid(configCompany);
	    	
	    	jQuery("#add").bind("click",function(){
	    			showDialog("增加单位",728,285,"<%=request.getContextPath() %>/xtgl/company/companyAdd.html");
	    	});
	    	
	    	jQuery("#modify").bind("click",function(){
		    		//选中的行
	    			var ids = getChecked();
						if(ids.length!=1){
							alert("请先选定一条记录!");
							return false;
						}
						var url="<%=request.getContextPath() %>/xtgl/company/companyMod.html"; 
						url+="?ids="+ids;
						showDialog('修改单位信息',728,285,url);
	    	});

	    	jQuery("#delete").bind("click",function(){
	    		//选中的行
	         var id = jQuery("#tabGrid").jqGrid('getGridParam', 'selarrrow');
	         for (var i = 0 ; i < id.length ; i++){
							var row = jQuery("#tabGrid").jqGrid('getRowData', id[i]);
							if(row.counts != "0"){
								alert("已有用户绑定选择的单位，不能删除!");
								return false;
							}
	         }
	    		 plcz("<%=request.getContextPath() %>/xtgl/company/companyDel.html","删除");
	    	});
	    });
	    
	    /**
		    * 检索
		    * @param tabId
		    * @param jsonMap
		    */
	    function searchResult() {
	    	var map = {};
	    	map["company_name"] = jQuery('#companyName').val();
	    	search('tabGrid',map);
	    }

    </script>
</html>
